package com.zzccyy.jpdemo.utils;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zzccyy.jpdemo.R;
import com.zzccyy.jpdemo.bean.ZcBean;

import java.util.List;


public class ListAdapter4 extends BaseQuickAdapter<ZcBean.Data, BaseViewHolder> {


    private final Context activity;


    public ListAdapter4(Context activity, int layoutResId) {
        super(layoutResId);
        this.activity = activity;
    }

    @Override
    protected void convert(BaseViewHolder helper, ZcBean.Data item) {
        ImageView ivvv = helper.getView(R.id.ivvv);
        TextView ttt1 = helper.getView(R.id.ttt1);
        TextView ttt2 = helper.getView(R.id.ttt2);
        TextView ttt3 = helper.getView(R.id.ttt3);
        double allPrice=0;
        for (int i = 0; i < getData().size(); i++) {
            allPrice+= getData().get(i).price;
        }
        double price = (item.price / allPrice) * 100;

        ttt2.setText(item.price +"");
        ttt3.setText(String.format("%.2f",price)+"%");
        if (item.type ==1){
            ivvv.setImageResource(R.mipmap.icfff1);
            ttt1.setText("交通费");
        }else if (item.type ==2){
            ivvv.setImageResource(R.mipmap.icfff2);
            ttt1.setText("住宿费");
        }else if (item.type ==3){
            ivvv.setImageResource(R.mipmap.icfff3);
            ttt1.setText("餐饮支出");
        }else if (item.type ==4){
            ivvv.setImageResource(R.mipmap.icfff4);
            ttt1.setText("门票支出");
        }else if (item.type ==5){
            ivvv.setImageResource(R.mipmap.icfff5);
            ttt1.setText("其他费用");
        }

    }
}

